<!DOCTYPt html>
<html>
<head>
<meta charset="utf-8">
<title></title>
  <script type="text/javascript">
    //函数格式
    function js(){
    //获取第一个数字
    var num1 = document.getElementById('n1').value;
    //把num1转换为数字:int float
    num1 = parseFloat(num1);
    //获取第二个数字
    var num2 = document.getElementById("n2").value;
    num2 = parseFloat(num2);
    //计算结果
    var sum = num1+num2;
    //把结果赋值到第三个文本框
    document.getElementById("n3").value=sum;
    }
  </script>
  </head>
  <body>
  第一个数：<input id="n1" type="text" />
  <br>
  第二个数：<input id="n2" type="text" />
  <br>
  &nbsp;&nbsp;&nbsp;&nbsp;
  &nbsp;&nbsp;&nbsp;&nbsp;
  &nbsp;&nbsp;&nbsp;&nbsp;
  &nbsp;
  <button onclick="js()">+</button>
  &nbsp;&nbsp;&nbsp;&nbsp;
  <button>-</button>
  &nbsp;&nbsp;&nbsp;&nbsp;
  <button>*</button>
  &nbsp;&nbsp;&nbsp;&nbsp;
  <button>/</button>
  <br>
  计算结果：<input id="n3" type="text" />
  <br>
  </body>
</html>
